#include <time.h>
#include <stdlib.h>
#include <stdio.h>

/*抢30*/
int input(int t);
int copu(int s);
void main()
{
    int tol=0;
    printf("\n*********catch thirty***********\n");
    printf("Game Begin\n");
    randomize();
    if(random(2)==1)
    tol=input(tol);
    while(tol!=30)
    if((tol=copu(tol))==30)
        printf("YOU LOSE!\n");
        else
        if((tol=input(tol))==30)
        printf("I LOSE!\n");
    printf("*************Game Over************\n");
}

int input(int t)
{
    int a;
    do
    {
        printf("Please count:");
        scanf("%d",&a);
        if(a>2||a<1||t+a>30)
        printf("error input ,again!");
        else
        printf("u count :%d\n",t+a);
    }while(a>2||a<1||t+a>30);
    return (t+a);
}

int copu(int s)
{
    int c;
    printf("Computer count:");
    if((s+1)%3==0)
    printf("%d\n",++s);
    else if((s+2)%3==0){
        s+=2;
        printf("%d\n",s);
    }
    else {
        c=random(2)+1;
        s+=c;
        printf("%d\n",s);

    }
    return s;
}
